﻿package plugin.taskdialog.ui
{
    import com.core.*;
    import com.sh.game.display.*;
    import com.sh.game.global.*;
    import com.sh.game.util.*;
    import consts.*;
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    import flash.utils.*;
    import manager.*;
    import morn.core.components.*;
    import morn.core.handlers.*;
    import plugin.taskdialog.*;
    import plugin.taskdialog.component.*;
    import plugin.taskdialog.consts.*;
    import pluginfw.nio.*;
    import uiresource.*;
    import view.*;
    import view.message.*;
    import view.mornExtends.*;
    import view.uilt.*;
    import vo.*;

    public class TaskDialogUICtrl extends taskDialogUI
    {
        private var _close:Function;
        private var starImg1:Image;
        private var starImg2:Image;
        private var starImg3:Image;
        private var starImg4:Image;
        private var starImg5:Image;
        private var starImg6:Image;
        private var starImg7:Image;
        private var starImg8:Image;
        private var starImg9:Image;
        private var starImg10:Image;
        private var cfgTaskNum:Object;
        private var taskstarrewardsContainer:Sprite;
        private var _typeArr:Array;
        private var _starArr:Array;
        private var _pdvisible:Boolean = false;
        private var timeoutID:uint;
        private var timeoutID1:uint;
        private var mtype:int = 1;
        private var mstar:int = 1;
        private var mstar_1:int = 1;
        private var cfgtask:Object;
        private var cfgnpcs:Object;
        private var cfgitem:Object;
        private var shop:Object;
        private var cfgtaskguide:Object;
        private var cfgGuanzhi:Array;
        private var _cfgtequan:Object;
        private var taskid:int;
        private var _rsprite:Sprite;
        private var _taskTitle:Image;
        private var _titleName:Image;
        private var _taskObj:Object;
        private var lasttime:int;
        private var star1_1:XMLMovieClip;
        private var star1_2:XMLMovieClip;
        private var star1_3:XMLMovieClip;
        private var star1_4:XMLMovieClip;
        private var star1_5:XMLMovieClip;
        private var star1_6:XMLMovieClip;
        private var star1_7:XMLMovieClip;
        private var star1_8:XMLMovieClip;
        private var star1_9:XMLMovieClip;
        private var star1_10:XMLMovieClip;
        private var star2_1:XMLMovieClip;
        private var star2_2:XMLMovieClip;
        private var star2_3:XMLMovieClip;
        private var star2_4:XMLMovieClip;
        private var star2_5:XMLMovieClip;
        private var star2_6:XMLMovieClip;
        private var star2_7:XMLMovieClip;
        private var star2_8:XMLMovieClip;
        private var star2_9:XMLMovieClip;
        private var star2_10:XMLMovieClip;
        private var _isshow:Boolean = true;
        private var npcid:int;
        private var freenum:int;
        private var state:int;
        private var rewardsArr:Array;
        private var starFlag:Boolean = false;
        private var tnobj:Object;
        private var anMc:XMLMovieClip;
        private var candotask:Object;
        private var cname:String;
        private var cfgmaps:Object;
        public static const anniuEffect:Class = TaskDialogUICtrl_anniuEffect;

        public function TaskDialogUICtrl(param1:Function)
        {
            this.cfgTaskNum = ConfigDictionary.data.tasknum;
            this.taskstarrewardsContainer = new Sprite();
            this._typeArr = new Array("", "主线", "支线", "日常", "经验", "采集", "女神", "宝箱");
            this._starArr = ["", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十"];
            this.cfgtask = ConfigDictionary.data.task;
            this.cfgnpcs = ConfigDictionary.data.sysnpc;
            this.cfgitem = ConfigDictionary.data.item;
            this.shop = ConfigDictionary.data.shop;
            this.cfgtaskguide = ConfigDictionary.data.taskguide;
            this.cfgGuanzhi = ConfigDictionary.data.guanwei;
            this._cfgtequan = ConfigDictionary.data.tequan;
            this.cfgmaps = ConfigDictionary.data.maplist;
            this._close = param1;
            return;
        }// end function

        override protected function initializeView() : void
        {
            super.initializeView();
            var _loc_1:* = Control.create(TaskDialogControl, this);
            ModelProxy.addObserver("taskdialog", _loc_1);
            normalContainer.visible = true;
            starContainer1.visible = false;
            starContainer3.visible = false;
            this._rsprite = new Sprite();
            normalContainer.addChild(this._rsprite);
            this.taskstarrewardsContainer = new Sprite();
            starContainer1.addChild(this.taskstarrewardsContainer);
            ModelProxy.change("guideitem", "guideid" + GuideType.GUIDE1, btn_jie);
            ModelProxy.change("guideitem", "guideid" + GuideType.GUIDE2, lingqu_btn);
            this.initEvent();
            this.initStar();
            XMLMcManager.instance.complatefuncs["taskdialog"] = this.showinit;
            return;
        }// end function

        private function showinit() : void
        {
            var _loc_1:int = 0;
            if (this._taskObj && this.star1_10 == null)
            {
                _loc_1 = this.cfgtask[this.taskid].type;
                if (_loc_1 == 4)
                {
                    this.show(this._taskObj);
                }
                else
                {
                    this.showEff();
                }
            }
            return;
        }// end function

        private function initStar() : void
        {
            var _loc_1:int = 0;
            _loc_1 = 1;
            while (_loc_1 <= 10)
            {
                
                this["star1_" + _loc_1] = XMLMcManager.instance.getPluginMc("taskdialog", "taskstar1", (_loc_1 - 1));
                if (this["star1_" + _loc_1])
                {
                    this["star1_" + _loc_1].interval = int(1000 / 8);
                    this["star1_" + _loc_1].mouseEnabled = false;
                    this["star1_" + _loc_1].mouseChildren = false;
                    this["star1_" + _loc_1].visible = false;
                    this["star1_" + _loc_1].autoPlay = false;
                    this["star1_" + _loc_1].x = -43 + (_loc_1 - 1) * 31;
                    this["star1_" + _loc_1].y = 260;
                    starContainer1.addChild(this["star1_" + _loc_1]);
                }
                _loc_1++;
            }
            _loc_1 = 1;
            while (_loc_1 <= 10)
            {
                
                this["star2_" + _loc_1] = XMLMcManager.instance.getPluginMc("taskdialog", "taskstar2", (_loc_1 - 1));
                if (this["star2_" + _loc_1])
                {
                    this["star2_" + _loc_1].interval = int(1000 / 8);
                    this["star2_" + _loc_1].mouseEnabled = false;
                    this["star2_" + _loc_1].mouseChildren = false;
                    this["star2_" + _loc_1].visible = false;
                    this["star2_" + _loc_1].autoPlay = false;
                    this["star2_" + _loc_1].x = -43 + (_loc_1 - 1) * 31;
                    this["star2_" + _loc_1].y = 260;
                    starContainer1.addChild(this["star2_" + _loc_1]);
                }
                _loc_1++;
            }
            this.showEff();
            return;
        }// end function

        private function showEff() : void
        {
            if (this.anMc == null)
            {
                this.anMc = XMLMcManager.instance.getPluginMc("taskdialog", "taskanniu");
                if (this.anMc)
                {
                    this.anMc.mouseEnabled = false;
                    this.anMc.mouseChildren = false;
                    this.anMc.blendMode = BlendMode.ADD;
                    this.anMc.autoPlay = true;
                    this.anMc.interval = 1000 / 8;
                    this.anMc.x = box_1.x - 155;
                    this.anMc.y = box_1.y - 175;
                    this.addChild(this.anMc);
                }
            }
            return;
        }// end function

        private function mcLoaded(param1) : void
        {
            var _loc_2:* = new XML(new anniuEffect());
            this.anMc = new XMLMovieClip("png.task.anniu", _loc_2);
            this.anMc.mouseEnabled = false;
            this.anMc.mouseChildren = false;
            this.anMc.blendMode = BlendMode.ADD;
            this.anMc.autoPlay = true;
            this.anMc.visible = false;
            this.anMc.interval = 1000 / 8;
            this.anMc.x = box_1.x - 155;
            this.anMc.y = box_1.y - 175;
            this.addChild(this.anMc);
            return;
        }// end function

        private function initEvent() : void
        {
            _buyCountBtn.addEventListener(MouseEvent.CLICK, this.buyCountHandler);
            _buy1CountBtn.addEventListener(MouseEvent.CLICK, this.buyCountHandler);
            _buyBtn.addEventListener(MouseEvent.CLICK, this.buyCountHandler);
            _buyCountBtn.addEventListener(MouseEvent.MOUSE_OVER, this.overHandler);
            _buyCountBtn.addEventListener(MouseEvent.MOUSE_OUT, this.outHandler);
            _buy1CountBtn.addEventListener(MouseEvent.MOUSE_OVER, this.overHandler);
            _buy1CountBtn.addEventListener(MouseEvent.MOUSE_OUT, this.outHandler);
            _buyBtn.addEventListener(MouseEvent.MOUSE_OVER, this.overHandler);
            _buyBtn.addEventListener(MouseEvent.MOUSE_OUT, this.outHandler);
            _flushLvBtn.addEventListener(MouseEvent.CLICK, this.flushLevelHandler);
            _yjsxBtn.addEventListener(MouseEvent.CLICK, this.shixingHandler);
            _yjwcBtn.addEventListener(MouseEvent.CLICK, this.yijianHandler);
            dan_btn.addEventListener(MouseEvent.CLICK, this.goumai1Handler);
            shuang_btn.addEventListener(MouseEvent.CLICK, this.goumai2Handler);
            san_btn.addEventListener(MouseEvent.CLICK, this.goumai3Handler);
            closeBtn.addEventListener(MouseEvent.CLICK, this.onClose);
            lingqu_btn.addEventListener(MouseEvent.CLICK, this.onSureHandler);
            btn_jie.addEventListener(MouseEvent.CLICK, this.jieShou);
            _jieshouBtn.addEventListener(MouseEvent.CLICK, this.jieShou);
            dan_btn.addEventListener(MouseEvent.MOUSE_OVER, this.mouseOver);
            shuang_btn.addEventListener(MouseEvent.MOUSE_OVER, this.mouseOver);
            san_btn.addEventListener(MouseEvent.MOUSE_OVER, this.mouseOver);
            dan_btn.addEventListener(MouseEvent.MOUSE_OUT, this.mouseOut);
            shuang_btn.addEventListener(MouseEvent.MOUSE_OUT, this.mouseOut);
            san_btn.addEventListener(MouseEvent.MOUSE_OUT, this.mouseOut);
            up_gz.addEventListener(MouseEvent.CLICK, this.upClickHandler);
            return;
        }// end function

        protected function outHandler(event:MouseEvent) : void
        {
            ModelProxy.change("tips", "state", "close");
            return;
        }// end function

        protected function overHandler(event:MouseEvent) : void
        {
            ModelProxy.change("tips", "normal", "购买一次需要花费" + MColor.getHMTL("50", 61) + "元宝");
            return;
        }// end function

        protected function upClickHandler(event:MouseEvent) : void
        {
            ModelProxy.change("plugin", "change", {target:"guanwei", point:new Point(100, 100), data:0});
            return;
        }// end function

        private function mouseOver(event:MouseEvent) : void
        {
            var _loc_4:Array = null;
            var _loc_5:Object = null;
            var _loc_6:Object = null;
            var _loc_7:Object = null;
            var _loc_2:* = event.currentTarget as Button;
            var _loc_3:Number = 1;
            if (_loc_2 == shuang_btn)
            {
                _loc_3 = 2;
            }
            else if (_loc_2 == san_btn)
            {
                _loc_3 = 3;
            }
            if (this.rewardsArr.length > 0)
            {
                _loc_4 = [];
                for each (_loc_5 in this.rewardsArr)
                {
                    
                    _loc_6 = null;
                    if (this.cfgitem[_loc_5.itemid])
                    {
                        _loc_6 = ItemObject.create(this.cfgitem[_loc_5.itemid]);
                        _loc_6.count = _loc_5.count * _loc_3;
                    }
                    _loc_4.push(_loc_6);
                }
                if (this.cfgtask[this.taskid].shengwang)
                {
                    _loc_7 = null;
                    if (this.cfgitem[_loc_5.itemid])
                    {
                        _loc_7 = ItemObject.create(this.cfgitem[11]);
                        _loc_7.count = this.cfgtask[this.taskid].shengwang;
                    }
                    _loc_4.push(_loc_7);
                }
                star_rw.array = _loc_4;
                star_rw1.array = _loc_4;
            }
            return;
        }// end function

        private function mouseOut(event:MouseEvent) : void
        {
            var _loc_2:Array = null;
            var _loc_3:Object = null;
            var _loc_4:Object = null;
            var _loc_5:Object = null;
            if (this.rewardsArr.length > 0)
            {
                _loc_2 = [];
                for each (_loc_3 in this.rewardsArr)
                {
                    
                    _loc_4 = null;
                    if (this.cfgitem[_loc_3.itemid])
                    {
                        _loc_4 = ItemObject.create(this.cfgitem[_loc_3.itemid]);
                        _loc_4.count = _loc_3.count;
                    }
                    _loc_2.push(_loc_4);
                }
                if (this.cfgtask[this.taskid].shengwang)
                {
                    _loc_5 = null;
                    if (this.cfgitem[_loc_3.itemid])
                    {
                        _loc_5 = ItemObject.create(this.cfgitem[11]);
                        _loc_5.count = this.cfgtask[this.taskid].shengwang;
                    }
                    _loc_2.push(_loc_5);
                }
                star_rw.array = _loc_2;
                star_rw1.array = _loc_2;
            }
            return;
        }// end function

        public function show(param1:Object) : void
        {
            this.taskid = param1.taskid;
            var _loc_2:* = this.cfgtask[this.taskid].type;
            lab_wk.visible = false;
            if (_loc_2 == 4)
            {
                normalContainer.visible = false;
                starContainer1.visible = true;
                this.initStar();
                this.showStarTask(param1);
            }
            else
            {
                normalContainer.visible = true;
                starContainer1.visible = false;
                starContainer3.visible = false;
                this.initStar();
                this.showNormal(param1);
            }
            this._taskObj = param1;
            return;
        }// end function

        public function flushlevel(param1:Object) : void
        {
            this.starFlag = true;
            var _loc_2:* = param1[1];
            var _loc_3:* = ModelProxy.getValue("data", "tasks");
            _loc_3["tid_" + this.taskid].star = _loc_2.star;
            this.mstar = _loc_2.star;
            taskjibiedesc.text = this._starArr[_loc_2.star] + "级任务<font color=\'#fdfdfd\'>（最高十级）</font>";
            ModelProxy.change("movetips", "error", "刷新成功，当前任务等级为" + this._starArr[_loc_2.star] + "级");
            this.show({taskid:this.taskid, npcid:this.npcid});
            return;
        }// end function

        public function updateCount() : void
        {
            var _loc_4:int = 0;
            var _loc_1:int = 3;
            var _loc_2:* = ModelProxy.getValue("data", "tasks");
            var _loc_3:* = this.cfgtask[this.taskid].taskgroupid;
            _loc_1 = 10 - int(_loc_2["group_" + _loc_3]);
            if (_loc_1 < 0)
            {
                _loc_1 = 0;
            }
            if (_loc_1 == 0)
            {
                taskcountdesc.text = "您今天的" + this.cfgtask[this.taskid].name + "任务剩余<font color=\'#FF0000\'>   " + _loc_1 + "   </font>次";
            }
            else
            {
                taskcountdesc.text = "您今天的" + this.cfgtask[this.taskid].name + "任务剩余<font color=\'#00FF00\'>   " + _loc_1 + "   </font>次";
            }
            if (this.cfgtask[this.taskid].type == 4)
            {
                if (_loc_1 > 0)
                {
                    _loc_4 = _loc_2["tid_" + this.taskid].star;
                    _yjsxBtn.visible = true;
                    _jieshouBtn.visible = true;
                    _flushLvBtn.visible = true;
                    _buyBtn.visible = false;
                    if (_loc_4 == 10)
                    {
                        GuideView.getInstance().doGuide(GuideType.GUIDE_XY2);
                    }
                    else
                    {
                        GuideView.getInstance().doGuide(GuideType.GUIDE_XY1);
                    }
                }
                else
                {
                    _buyBtn.visible = true;
                    _yjsxBtn.visible = false;
                    _jieshouBtn.visible = false;
                    _flushLvBtn.visible = false;
                }
            }
            return;
        }// end function

        private function showNormal(param1:Object) : void
        {
            var _loc_13:Object = null;
            var _loc_14:Object = null;
            var _loc_15:Object = null;
            this.visible = true;
            if (this.anMc)
            {
                this.anMc.visible = false;
            }
            this.npcid = param1.npcid;
            this.mtype = 1;
            var _loc_2:* = ConfigDictionary.data.npc;
            var _loc_3:* = ModelProxy.getValue("data", "tasks");
            this.state = _loc_3["tid_" + this.taskid].state;
            this.mstar = _loc_3["tid_" + this.taskid].star;
            this.pdvisible = false;
            lingqu_btn.mouseEnabled = true;
            lingqu_btn.visible = false;
            btn_jie.mouseEnabled = true;
            btn_jie.visible = false;
            var _loc_4:String = "";
            var _loc_5:* = ModelProxy.getValue("data", "user.level");
            var _loc_6:* = ModelProxy.getValue("data", "user.rein");
            if (this.state == 1)
            {
                _loc_4 = this.cfgtask[this.taskid].tip1;
                btn_jie.visible = true;
                this.pdvisible = true;
                if (this.anMc)
                {
                    this.anMc.visible = true;
                }
                if (_loc_5 <= 65)
                {
                    NewGuideView.getInstance().doGuide(GuideType.GUIDE1);
                }
            }
            else if (this.state == 2)
            {
                if (this.cfgtask[this.taskid].submitType > 0)
                {
                    _loc_4 = this.cfgtask[this.taskid].tip3;
                    lingqu_btn.visible = true;
                    this.pdvisible = true;
                }
                else
                {
                    _loc_4 = this.cfgtask[this.taskid].tip1;
                }
            }
            else if (this.state == 3)
            {
                _loc_4 = this.cfgtask[this.taskid].tip3;
                lingqu_btn.visible = true;
                this.pdvisible = true;
                if (this.anMc)
                {
                    this.anMc.visible = true;
                }
                if (_loc_5 <= 70 && _loc_6 == 0)
                {
                    NewGuideView.getInstance().doGuide(GuideType.GUIDE2);
                }
            }
            var _loc_7:int = 1;
            if (_loc_4.indexOf("#") > -1)
            {
                _loc_7 = _loc_4.split("#").length;
                _loc_4 = _loc_4.replace(/#""#/g, "\n");
            }
            lingqutext.text = _loc_4;
            var _loc_8:* = this.cfgtask[this.taskid].rewards;
            var _loc_9:int = 0;
            var _loc_10:Array = [];
            var _loc_11:* = UserData.getUserData("career");
            var _loc_12:* = UserData.getUserData("sex");
            for each (_loc_13 in _loc_8)
            {
                
                if (_loc_13 == null)
                {
                    continue;
                }
                _loc_14 = null;
                if (this.cfgitem[_loc_13.itemid])
                {
                    _loc_14 = ItemObject.create(this.cfgitem[_loc_13.itemid]);
                    _loc_14.count = _loc_13.count;
                }
                if (_loc_13.career == 0)
                {
                    if (_loc_13.sex == 2)
                    {
                        _loc_10.push(_loc_14);
                        _loc_9++;
                    }
                    else if (_loc_13.sex == _loc_12)
                    {
                        _loc_10.push(_loc_14);
                        _loc_9++;
                    }
                    continue;
                }
                if (_loc_13.career == _loc_11)
                {
                    if (_loc_13.sex == 2)
                    {
                        _loc_10.push(_loc_14);
                        _loc_9++;
                        continue;
                    }
                    if (_loc_13.sex == _loc_12)
                    {
                        _loc_10.push(_loc_14);
                        _loc_9++;
                    }
                }
            }
            if (this.cfgtask[this.taskid].shengwang)
            {
                _loc_15 = null;
                if (this.cfgitem[_loc_13.itemid])
                {
                    _loc_15 = ItemObject.create(this.cfgitem[11]);
                    _loc_15.count = this.cfgtask[this.taskid].shengwang;
                }
                _loc_10.push(_loc_15);
            }
            jiangliwupin.array = _loc_10;
            jiangliwupin.renderHandler = new Handler(this.mlistrender);
            if (this.timeoutID)
            {
                clearTimeout(this.timeoutID);
                this.timeoutID = 0;
            }
            if (!Config.isYaCe)
            {
                if (btn_jie.visible)
                {
                    this.timeoutID = setTimeout(this.sure, 500);
                }
                else
                {
                    this.timeoutID = setTimeout(this.sure, 15000);
                }
            }
            box_1.visible = btn_jie.visible;
            box_2.visible = lingqu_btn.visible;
            return;
        }// end function

        private function mlistrender(param1:Component, param2:int) : void
        {
            if (param2 < jiangliwupin.length)
            {
                (param1 as FlashItem).data = jiangliwupin.array[param2];
            }
            return;
        }// end function

        private function sure() : void
        {
            if (this.timeoutID > 0)
            {
                if (btn_jie.visible)
                {
                    this.jieShou(null);
                }
                else if (lingqu_btn.visible)
                {
                    this.onSureHandler(null);
                }
            }
            return;
        }// end function

        public function checkHZCInBag(param1:Boolean = true) : Boolean
        {
            var _loc_4:Object = null;
            var _loc_5:Object = null;
            var _loc_6:Object = null;
            var _loc_7:Object = null;
            var _loc_2:* = UserData.getBagData();
            var _loc_3:* = this.candig();
            if (_loc_2)
            {
                for (_loc_6 in _loc_2)
                {
                    
                    _loc_5 = _loc_2[_loc_6];
                    if (_loc_5.hasOwnProperty("4"))
                    {
                        _loc_7 = _loc_5[4];
                        if (_loc_7 && _loc_7.hasOwnProperty("itemid") && _loc_7.itemid == 140102001)
                        {
                            _loc_3 = true;
                            break;
                        }
                    }
                }
            }
            if (_loc_3 == false)
            {
                _loc_5 = ItemObject.create(this.cfgitem[140102001]);
                _loc_5.sellvalue = 3000;
                DialogMgr.instance.open(AppDialog.SURE_BAY_DIALOG, _loc_5);
                ModelProxy.change("data", "digflag", true);
            }
            return _loc_3;
        }// end function

        private function candig() : Boolean
        {
            var _loc_1:Boolean = false;
            var _loc_2:* = ModelProxy.getValue("data", "arms");
            if (_loc_2)
            {
                if (_loc_2[1] && _loc_2[1].itemid == 140102001)
                {
                    _loc_1 = true;
                }
            }
            return _loc_1;
        }// end function

        private function showRichange(param1:Object) : void
        {
            var _loc_14:Object = null;
            var _loc_15:NewRewardListItem = null;
            var _loc_16:NewRewardListItem = null;
            var _loc_17:Object = null;
            this.npcid = param1.npcid;
            var _loc_2:* = ConfigDictionary.data.npc;
            var _loc_3:* = ModelProxy.getValue("data", "tasks");
            var _loc_4:* = _loc_3["tid_" + this.taskid];
            if (!_loc_3["tid_" + this.taskid])
            {
                ModelProxy.change("movetips", "error", "条件不满足,不能触发任务");
                this.close();
                return;
            }
            var _loc_5:* = _loc_4.state;
            this.mstar = _loc_3["tid_" + this.taskid].star;
            lingqu_btn.visible = false;
            this.pdvisible = false;
            lingqu_btn.mouseEnabled = true;
            var _loc_6:String = "";
            var _loc_7:* = ModelProxy.getValue("data", "user.level");
            if (_loc_5 == 1)
            {
                _loc_6 = this.cfgtask[this.taskid].say;
                lingqu_btn.visible = true;
                if (_loc_7 <= 61)
                {
                    NewGuideView.getInstance().doGuide(GuideType.GUIDE1);
                }
            }
            else if (_loc_5 == 2)
            {
                _loc_6 = this.cfgtask[this.taskid].tip1;
            }
            else if (_loc_5 == 3)
            {
                _loc_6 = this.cfgtask[this.taskid].desc;
                lingqu_btn.visible = true;
                if (_loc_7 <= 61)
                {
                    NewGuideView.getInstance().doGuide(GuideType.GUIDE2);
                }
            }
            var _loc_8:int = 1;
            if (_loc_6.indexOf("#") > -1)
            {
                _loc_8 = _loc_6.split("#").length;
                _loc_6 = _loc_6.replace(/#""#/g, "\n");
            }
            var _loc_9:* = this.cfgtask[this.taskid].rewards;
            var _loc_10:* = this.cfgtask[this.taskid].type;
            var _loc_11:int = 3;
            var _loc_12:* = this.cfgtask[this.taskid].taskgroupid;
            _loc_11 = 10 - int(_loc_3["group_" + _loc_12]);
            if (_loc_11 < 0)
            {
                _loc_11 = 0;
            }
            if (_loc_11 == 0)
            {
                taskcountdesc.text = "您今天的" + this.cfgtask[this.taskid].name + "任务剩余<font color=\'#FF0000\'>   " + _loc_11 + "   </font>次";
            }
            else
            {
                taskcountdesc.text = "您今天的" + this.cfgtask[this.taskid].name + "任务剩余<font color=\'#00FF00\'>   " + _loc_11 + "   </font>次";
            }
            if (taskdesctext && taskdesctext)
            {
            }
            taskdesctext.text = _loc_6;
            if (_loc_5 == 2)
            {
                this.lingqu_btn.visible = false;
            }
            else
            {
                this.lingqu_btn.visible = true;
            }
            var _loc_13:int = 0;
            while (this.taskstarrewardsContainer.numChildren > 0)
            {
                
                _loc_15 = this.taskstarrewardsContainer.removeChildAt(0) as NewRewardListItem;
                if (_loc_15)
                {
                    _loc_15.dispose();
                    _loc_15 = null;
                }
            }
            for each (_loc_14 in _loc_9)
            {
                
                _loc_16 = new NewRewardListItem();
                _loc_17 = ItemObject.create(this.cfgitem[_loc_14.itemid]);
                _loc_17.count = _loc_14.count;
                _loc_16.data = _loc_17;
                _loc_16.x = 4 - 36;
                _loc_16.y = 50 * _loc_13;
                this.taskstarrewardsContainer.addChild(_loc_16);
                _loc_13++;
            }
            return;
        }// end function

        private function showStarTask(param1:Object) : void
        {
            var mtype1:int;
            var i:int;
            var item1:Object;
            var bag:Object;
            var obj1:Object;
            var guanzhi:int;
            var costArr:Array;
            var cstr1:String;
            var carr1:Array;
            var cstr2:String;
            var carr2:Array;
            var obj2:Object;
            var temp:Object;
            var temp1:Object;
            var obj:* = param1;
            this.npcid = obj.npcid;
            var cfgNpc:* = ConfigDictionary.data.npc;
            var task:* = ModelProxy.getValue("data", "tasks");
            var state:* = task["tid_" + this.taskid].state;
            var star:* = task["tid_" + this.taskid].star;
            this.mstar = star;
            this.pdvisible = false;
            if (this.anMc)
            {
                this.anMc.visible = false;
            }
            var desc:String;
            var lv:* = ModelProxy.getValue("data", "user.level");
            if (state == 1)
            {
                desc = this.cfgtask[this.taskid].tip1;
            }
            else if (state == 2)
            {
                desc = this.cfgtask[this.taskid].tip3;
            }
            else if (state == 3)
            {
                desc = this.cfgtask[this.taskid].tip2;
            }
            var h:int;
            if (desc.indexOf("#") > -1)
            {
                h = desc.split("#").length;
                desc = desc.replace(/#""#/g, "\n");
            }
            this.rewardsArr = this.cfgtask[this.taskid].rewards;
            var cost:* = this.cfgtask[this.taskid].cost;
            var type:* = this.cfgtask[this.taskid].type;
            var count:int;
            var group:* = this.cfgtask[this.taskid].taskgroupid;
            count = 10 - int(task["group_" + group]);
            if (count < 0)
            {
                count;
            }
            _buy1CountBtn.visible = false;
            _buyCountBtn.visible = false;
            chishu_txtDec.isHtml = true;
            if (count == 0)
            {
                var _loc_3:* = "您今天的" + this.cfgtask[this.taskid].name + "任务剩余<font color=\'#FF0000\'>   " + count + "   </font>次";
                taskcountdesc.text = "您今天的" + this.cfgtask[this.taskid].name + "任务剩余<font color=\'#FF0000\'>   " + count + "   </font>次";
                chishu_txtDec.text = _loc_3;
            }
            else
            {
                var _loc_3:* = "您今天的" + this.cfgtask[this.taskid].name + "任务剩余<font color=\'#00FF00\'>   " + count + "   </font>次";
                taskcountdesc.text = "您今天的" + this.cfgtask[this.taskid].name + "任务剩余<font color=\'#00FF00\'>   " + count + "   </font>次";
                chishu_txtDec.text = _loc_3;
            }
            if (state == 1)
            {
                starContainer3.visible = false;
                taskdesctext.visible = true;
                taskdesctext.width = 293;
                taskdesctext.height = 40;
                taskdesctext.color = 11908533;
                taskdesctext.wordWrap = true;
                taskdesctext.multiline = true;
                taskdesctext.leading = 3;
                taskdesctext.text = desc;
                this.taskstarrewardsContainer.x = 40;
                manxing.visible = false;
                mtype1;
                if (star < 4)
                {
                    taskjibiedesc.text = "<font color=\'#00ff00\'>" + this._starArr[star] + "级任务</font>（最高十级）";
                }
                else if (star < 7)
                {
                    mtype1;
                    taskjibiedesc.text = "<font color=\'#00b0f0\'>" + this._starArr[star] + "级任务</font>（最高十级）</font>";
                }
                else if (star < 10)
                {
                    mtype1;
                    taskjibiedesc.text = "<font color=\'#b23aee\'>" + this._starArr[star] + "级任务</font>（最高十级）</font>";
                }
                else
                {
                    mtype1;
                    taskjibiedesc.text = "<font color=\'#ff6600\'>" + this._starArr[star] + "级任务</font>（最高十级）</font>";
                    manxing.visible = true;
                }
                bag = UserData.getBagData();
                obj1 = UserData.getOnlineData("guide");
                if (count > 0)
                {
                    _yjsxBtn.visible = true;
                    _jieshouBtn.visible = true;
                    _flushLvBtn.visible = true;
                    _buyBtn.visible = false;
                    guanzhi = UserData.getUserData("guanzhi");
                    if (guanzhi < 1 && bag.shengwang >= this.cfgGuanzhi[1].count && int(obj1[GuideType.GUIDE_GZ]) == 0 && ItemUilt.checkUserLevelRein(int(this.cfgGuanzhi[1].level), 0))
                    {
                        GuideView.getInstance().doGuide(GuideType.GUIDE_GZ);
                    }
                    else if (guanzhi < 2 && bag.shengwang >= this.cfgGuanzhi[2].count && int(obj1[GuideType.GUIDE_GZ2]) == 0 && ItemUilt.checkUserLevelRein(int(this.cfgGuanzhi[2].level), 0))
                    {
                        GuideView.getInstance().doGuide(GuideType.GUIDE_GZ2);
                    }
                    else if (star == 10)
                    {
                        GuideView.getInstance().doGuide(GuideType.GUIDE_XY2);
                    }
                    else
                    {
                        GuideView.getInstance().doGuide(GuideType.GUIDE_XY1);
                    }
                }
                else
                {
                    guanzhi = UserData.getUserData("guanzhi");
                    if (guanzhi < 1 && bag.shengwang >= this.cfgGuanzhi[1].count && int(obj1[GuideType.GUIDE_GZ]) == 0 && ItemUilt.checkUserLevelRein(int(this.cfgGuanzhi[1].level), 0))
                    {
                        GuideView.getInstance().doGuide(GuideType.GUIDE_GZ);
                    }
                    else if (guanzhi < 2 && bag.shengwang >= this.cfgGuanzhi[2].count && int(obj1[GuideType.GUIDE_GZ2]) == 0 && ItemUilt.checkUserLevelRein(int(this.cfgGuanzhi[2].level), 0))
                    {
                        GuideView.getInstance().doGuide(GuideType.GUIDE_GZ2);
                    }
                    else
                    {
                        GuideView.getInstance().doGuide(GuideType.GUIDE_GM);
                    }
                    _buyBtn.visible = true;
                    _yjsxBtn.visible = false;
                    _jieshouBtn.visible = false;
                    _flushLvBtn.visible = false;
                }
                taskjibiedesc.visible = true;
                _buy1CountBtn.visible = true;
            }
            else
            {
                starContainer3.visible = true;
                starContainer1.visible = false;
                taskdesctext.visible = true;
                _buyCountBtn.visible = true;
                miaoshu_txtDec.text = desc;
                mtype1;
                if (star < 4)
                {
                    taskjibiedesc.text = "<font color=\'#00ff00\'>" + this._starArr[star] + "级任务</font>（最高十级）";
                }
                else if (star < 7)
                {
                    mtype1;
                    taskjibiedesc.text = "<font color=\'#00b0f0\'>" + this._starArr[star] + "级任务</font>（最高十级）</font>";
                }
                else if (star < 10)
                {
                    mtype1;
                    taskjibiedesc.text = "<font color=\'#b23aee\'>" + this._starArr[star] + "级任务</font>（最高十级）</font>";
                }
                else
                {
                    mtype1;
                    taskjibiedesc.text = "<font color=\'#ff6600\'>" + this._starArr[star] + "级任务</font>（最高十级）</font>";
                }
                this.taskstarrewardsContainer.x = 40;
                if (state == 3)
                {
                    dan_btn.visible = true;
                    shuang_btn.visible = true;
                    san_btn.visible = true;
                    if (cost != "1")
                    {
                        costArr = cost.split("&");
                        if (costArr.length > 1)
                        {
                            cstr1 = costArr[1];
                            carr1 = cstr1.split("#");
                            cstr2 = costArr[2];
                            carr2 = cstr2.split("#");
                            txt_double.visible = true;
                            txt_three.visible = true;
                            txt_double.text = "2倍领取：花费" + MColor.getHMTL(carr1[1] + "", 8) + this.cfgitem[carr1[0]].name;
                            txt_three.text = "3倍领取：花费" + MColor.getHMTL(carr2[1] + "", 8) + this.cfgitem[carr2[0]].name;
                        }
                    }
                    GuideView.getInstance().doGuide(GuideType.GUIDE_XY3);
                }
                else
                {
                    txt_double.visible = false;
                    txt_three.visible = false;
                    dan_btn.visible = false;
                    shuang_btn.visible = false;
                    san_btn.visible = false;
                }
            }
            var starArr:Array;
            i;
            while (i <= 10)
            {
                
                obj2 = new Object();
                if (i <= star)
                {
                    obj2.state = 1;
                    obj2.star = this.mstar_1;
                    obj2.flag = this.starFlag;
                    starArr.push(obj2);
                }
                else if (i <= this.mstar_1)
                {
                    obj2.state = 0;
                    obj2.star = this.mstar_1;
                    obj2.flag = this.starFlag;
                    starArr.push(obj2);
                    if (this["star1_" + i])
                    {
                        this["star1_" + i].visible = false;
                    }
                }
                else if (this["star1_" + i])
                {
                    this["star1_" + i].visible = false;
                    this["star2_" + i].visible = false;
                }
                if (this["star1_" + i] && obj2)
                {
                    if (this.starFlag)
                    {
                        if (i <= this.mstar_1)
                        {
                            this["star2_" + i].visible = true;
                            this["star2_" + i].playFromTo(0, 9, new Handler(function () : void
            {
                star2stop(i);
                return;
            }// end function
            ));
                            if (obj2.state == 1)
                            {
                                setTimeout(this.dostar1, (i + 1) * 15 + 100, [i]);
                            }
                        }
                        else if (obj2.state == 1)
                        {
                            setTimeout(this.dostar1, (i + 1) * 15 + 100, [i]);
                        }
                    }
                    else if (i <= star)
                    {
                        this["star1_" + i].visible = true;
                        this["star1_" + i].frame = 12;
                    }
                    else
                    {
                        this["star1_" + i].visible = false;
                    }
                }
                else if (this["star1_" + i])
                {
                    this["star1_" + i].visible = false;
                }
                i = (i + 1);
            }
            this.starFlag = false;
            i;
            var gArr:Array;
            var _loc_3:int = 0;
            var _loc_4:* = this.rewardsArr;
            while (_loc_4 in _loc_3)
            {
                
                item1 = _loc_4[_loc_3];
                temp;
                if (this.cfgitem[item1.itemid])
                {
                    temp = ItemObject.create(this.cfgitem[item1.itemid]);
                    temp.count = item1.count;
                }
                gArr.push(temp);
                i = (i + 1);
            }
            if (this.cfgtask[this.taskid].shengwang)
            {
                temp1;
                if (this.cfgitem[item1.itemid])
                {
                    temp1 = ItemObject.create(this.cfgitem[11]);
                    temp1.count = this.cfgtask[this.taskid].shengwang;
                }
                gArr.push(temp1);
            }
            this.mstar_1 = star;
            star_rw.array = gArr;
            star_rw1.array = gArr;
            star_rw.renderHandler = new Handler(this.nlistrender);
            star_rw1.renderHandler = new Handler(this.nlistrender);
            return;
        }// end function

        private function dostar1(param1:int) : void
        {
            var i:* = param1;
            this["star1_" + i].visible = true;
            this["star1_" + i].playFromTo(0, 12, new Handler(function () : void
            {
                star1stop(i);
                return;
            }// end function
            ));
            return;
        }// end function

        private function star1stop(param1:int) : void
        {
            this["star1_" + param1].stop();
            if (param1 > this.mstar)
            {
                this["star1_" + param1].visible = false;
            }
            return;
        }// end function

        private function star2stop(param1:int) : void
        {
            this["star2_" + param1].stop();
            return;
        }// end function

        private function nlistrender(param1:Component, param2:int) : void
        {
            if (param2 < star_rw.length)
            {
                (param1 as FlashItem).data = star_rw.array[param2];
            }
            return;
        }// end function

        private function onSureHandler(event:MouseEvent) : void
        {
            var e:* = event;
            NewGuideView.getInstance().hide();
            if (this.timeoutID)
            {
                clearTimeout(this.timeoutID);
                this.timeoutID = 0;
            }
            this.mtype = 1;
            PluginManager.instance.sendToServer("taskdialog", CMDTaskdialog.Submit, [this.taskid, 1]);
            var p:* = lingqu_btn.localToGlobal(new Point(0, 0));
            ModelProxy.change("data", "itempoint", p);
            lingqu_btn.mouseEnabled = false;
            setTimeout(function () : void
            {
                lingqu_btn.mouseEnabled = true;
                return;
            }// end function
            , 1000);
            return;
        }// end function

        private function jieShou(event:MouseEvent) : void
        {
            var task:Object;
            var group:int;
            var gc:int;
            var num:int;
            var e:* = event;
            if (this.timeoutID)
            {
                clearTimeout(this.timeoutID);
                this.timeoutID = 0;
            }
            if (this.taskid == 2001)
            {
                task = ModelProxy.getValue("data", "tasks");
                group = this.cfgtask[this.taskid].taskgroupid;
                gc = int(task["group_" + group]);
                num = this.cfgTaskNum[group].num;
                if (gc >= num)
                {
                    WarningManager.show(129);
                    return;
                }
                if (this.checkHZCInBag() == false)
                {
                    return;
                }
            }
            PluginManager.instance.sendToServer("taskdialog", CMDTaskdialog.Accept, this.taskid);
            if (this.taskid == 2011)
            {
                ModelProxy.change("zone", "preloadskill", null);
            }
            btn_jie.mouseEnabled = false;
            setTimeout(function () : void
            {
                btn_jie.mouseEnabled = true;
                return;
            }// end function
            , 1000);
            return;
        }// end function

        private function shixingHandler(event:MouseEvent) : void
        {
            var e:* = event;
            Alert2.show("将消耗50元宝刷新为十星，是否继续", "", ["确定", "取消"], function (param1:int, param2:Object) : void
            {
                if (param1 == 0)
                {
                    PluginManager.instance.sendToServer("taskdialog", CMDTaskdialog.FlushTopLevel, taskid);
                }
                return;
            }// end function
            );
            return;
        }// end function

        private function yijianHandler(event:MouseEvent) : void
        {
            var e:* = event;
            Alert2.show("一键完成当前任务，消耗50元宝", "", ["确定", "取消"], function (param1:int, param2:Object) : void
            {
                if (param1 == 0)
                {
                    PluginManager.instance.sendToServer("taskdialog", CMDTaskdialog.FinishRichang, {taskid:taskid});
                }
                return;
            }// end function
            );
            return;
        }// end function

        private function buyCountHandler(event:MouseEvent) : void
        {
            var _loc_2:int = 0;
            var _loc_3:* = ModelProxy.getValue("data", "tasks");
            var _loc_4:* = this.cfgtask[this.taskid].taskgroupid;
            var _loc_5:* = ModelProxy.getValue("vip", "getvip");
            var _loc_6:* = ModelProxy.getValue("vip", "getvip").privilegeCardLevel;
            var _loc_7:* = int(_loc_3["buy_" + _loc_4]);
            if (_loc_6 < 1 && _loc_7 >= 5)
            {
                Alert2.show("您的免费次数已用完，只有月卡用户才能继续购买降妖伏魔次数，是否确认开通月卡？", "", ["确定", "取消"], this.buyCheckHandler1, null, false, true);
                return;
            }
            if (_loc_6 < 1)
            {
                _loc_2 = 5 - int(_loc_3["buy_" + _loc_4]);
            }
            else
            {
                _loc_2 = 5 + int(this._cfgtequan[_loc_6].fumotimes) - int(_loc_3["buy_" + _loc_4]);
            }
            if (_loc_2 <= 0)
            {
                ModelProxy.change("movetips", "error", "您今日额外购买降妖伏魔次数已用完！");
                return;
            }
            if (_loc_2 >= 1)
            {
                if (this._isshow)
                {
                    Alert2.show("你要消耗50元宝购买一次降妖伏魔次数", "", ["购买一次", "取消"], this.buyCheckHandler, null, false, true, true);
                }
                else
                {
                    PluginManager.instance.sendToServer("taskdialog", CMDTaskdialog.BuyCount, this.taskid);
                }
            }
            return;
        }// end function

        private function buyCheckHandler(param1:int, param2:Object) : void
        {
            if (param1 == 0)
            {
                PluginManager.instance.sendToServer("taskdialog", CMDTaskdialog.BuyCount, this.taskid);
            }
            else if (param1 == 100)
            {
                PluginManager.instance.sendToServer("taskdialog", CMDTaskdialog.BuyCount, this.taskid);
                this._isshow = false;
            }
            else if (param1 == 101)
            {
                this._isshow = false;
            }
            return;
        }// end function

        private function buyCheckHandler1(param1:int, param2:Object) : void
        {
            if (param1 == 0)
            {
                ModelProxy.change("plugin", "open", {target:"viptq"});
            }
            return;
        }// end function

        private function flushLevelHandler(event:MouseEvent) : void
        {
            if (this.mstar == 10)
            {
                ModelProxy.change("movetips", "error", "已经是最高等级");
                return;
            }
            PluginManager.instance.sendToServer("taskdialog", CMDTaskdialog.FlushLevel, this.taskid);
            return;
        }// end function

        private function goumai1Handler(event:MouseEvent) : void
        {
            ModelProxy.change("guide", "hide", GuideType.GUIDE_XY3);
            if (starContainer3.visible)
            {
                this.mtype = 1;
                PluginManager.instance.sendToServer("taskdialog", CMDTaskdialog.Submit, [this.taskid, 1]);
            }
            else
            {
                ModelProxy.change("movetips", "error", "任务未完成，不能领取奖励！");
            }
            return;
        }// end function

        private function goumai2Handler(event:MouseEvent) : void
        {
            ModelProxy.change("guide", "hide", GuideType.GUIDE_XY3);
            if (starContainer3.visible)
            {
                this.mtype = 2;
                PluginManager.instance.sendToServer("taskdialog", CMDTaskdialog.Submit, [this.taskid, 2]);
            }
            else
            {
                ModelProxy.change("movetips", "error", "任务未完成，不能领取奖励！");
            }
            return;
        }// end function

        private function goumai3Handler(event:MouseEvent) : void
        {
            if (starContainer3.visible)
            {
                this.mtype = 3;
                PluginManager.instance.sendToServer("taskdialog", CMDTaskdialog.Submit, [this.taskid, 3]);
            }
            else
            {
                ModelProxy.change("movetips", "error", "任务未完成，不能领取奖励！");
            }
            return;
        }// end function

        private function getCount(param1:Object, param2:int) : int
        {
            var _loc_4:Object = null;
            var _loc_5:Object = null;
            var _loc_6:int = 0;
            var _loc_3:int = 0;
            for (_loc_4 in param1)
            {
                
                _loc_5 = param1[_loc_4];
                if (_loc_5.hasOwnProperty("4"))
                {
                    if (_loc_5[2] == 2)
                    {
                        _loc_6 = _loc_5[1];
                        _loc_5 = _loc_5[4];
                        if (_loc_5 != null && _loc_5.hasOwnProperty("itemid"))
                        {
                            if (_loc_5.itemid == param2)
                            {
                                _loc_3 = _loc_3 + _loc_6;
                            }
                        }
                    }
                }
            }
            return _loc_3;
        }// end function

        public function changeState(param1:int, param2:int, param3:Long = null) : void
        {
            var _loc_5:Object = null;
            var _loc_6:int = 0;
            var _loc_7:Object = null;
            var _loc_8:Object = null;
            var _loc_9:int = 0;
            var _loc_4:* = ModelProxy.getValue("data", "tasks");
            if (param2 == 2)
            {
                if (param1 == 107)
                {
                    ModelProxy.change("zone", "stopGuaji", null);
                    ModelProxy.change("plugin", "open", {target:"ems", point:new Point(GlobalLayer.instance.root.stageWidth / 2, GlobalLayer.instance.root.stageHeight / 2 - 120), top:new Point((GlobalLayer.instance.root.stageWidth - 740) / 2, 100)});
                }
            }
            if (_loc_4["tid_" + param1])
            {
                _loc_4["tid_" + param1].state = param2;
                _loc_4["tid_" + param1].time = param3;
            }
            else
            {
                _loc_5 = new Object();
                _loc_5.state = param2;
                _loc_5.time = param3;
                _loc_5.taskid = param1;
                _loc_4["tid_" + param1] = _loc_5;
            }
            ModelProxy.change("zone", "updatetask", null);
            if (param2 == 3)
            {
                _loc_6 = this.cfgtask[param1].tnpc;
                _loc_7 = this.cfgnpcs[_loc_6];
                _loc_8 = UserData.getUserData();
                _loc_9 = _loc_8.mapid;
                if (this.cfgmaps[_loc_9] && this.cfgmaps[_loc_9].cls == 6)
                {
                    return;
                }
                if (_loc_7)
                {
                    if (this.cfgtask[param1].tnpc != this.cfgtask[param1].fnpc || (Math.abs(_loc_8.x - int(_loc_7.x)) > 5 || Math.abs(_loc_8.y - int(_loc_7.y)) > 5))
                    {
                        if (PluginManager.instance.getPluginState("taskdialog") == "open")
                        {
                            this.close();
                        }
                    }
                    else
                    {
                        this.show({npcid:_loc_7.npcid, taskid:param1});
                    }
                }
            }
            else if (param2 == 2)
            {
                this.close();
            }
            return;
        }// end function

        public function completeTask(param1:Object) : void
        {
            var _loc_3:int = 0;
            this.mtype = 1;
            ModelProxy.change("data", "taskfindwoman", false);
            ModelProxy.change("data", "tasks", param1);
            ModelProxy.change("zone", "updatetask", null);
            if (this.taskid == 68 || this.taskid == 78 || this.taskid == 156 || this.taskid == 379 || this.taskid == 414 || this.taskid == 449 || this.taskid == 484)
            {
                ModelProxy.change("mainui", "showTishi", 4);
            }
            var _loc_2:* = int(this.cfgtask[this.taskid].chapterstate);
            if (_loc_2 > 0)
            {
                _loc_3 = int(this.cfgtask[this.taskid].chapterid);
                ModelProxy.change("mainui", "taskeff", _loc_3);
            }
            return;
        }// end function

        public function checkNextTask(param1:Object, param2:int, param3:Boolean = false) : void
        {
            var _loc_4:Object = null;
            var _loc_5:Object = null;
            var _loc_7:Object = null;
            var _loc_8:int = 0;
            var _loc_9:int = 0;
            var _loc_10:Object = null;
            this.starFlag = param3;
            if (!this.starFlag)
            {
                this.mstar_1 = 0;
            }
            var _loc_6:* = ModelProxy.getValue("data", "tasks");
            this.candotask = null;
            if (!param3)
            {
                for each (_loc_4 in param1)
                {
                    
                    if (_loc_4 && _loc_4.hasOwnProperty("taskid"))
                    {
                        _loc_5 = this.cfgtask[_loc_4.taskid];
                        if (int(_loc_5.level) <= param2)
                        {
                            if (int(_loc_5.type) != 1 || _loc_4.state == 4)
                            {
                                continue;
                            }
                            this.candotask = _loc_4;
                            break;
                        }
                    }
                }
            }
            if (this.candotask == null)
            {
                for each (_loc_4 in param1)
                {
                    
                    if (_loc_4 && _loc_4.hasOwnProperty("taskid"))
                    {
                        _loc_5 = this.cfgtask[_loc_4.taskid];
                        if (_loc_4.state == 1 && _loc_5.type == 4)
                        {
                            this.candotask = _loc_4;
                            break;
                        }
                    }
                }
            }
            if (this.candotask == null)
            {
                this.close();
                return;
            }
            this.tnobj = null;
            if (this.cfgtask[this.candotask.taskid].type == 1 || this.cfgtask[this.candotask.taskid].type == 4)
            {
                if (this.cfgtaskguide[1] && this.cfgtaskguide[1][this.candotask.taskid] && this.cfgtaskguide[1][this.candotask.taskid].event == 2)
                {
                    _loc_4 = this.cfgtaskguide[1][this.candotask.taskid];
                    _loc_7 = UserData.getOnlineData("guide");
                    if (int(_loc_7[_loc_4.id]) == 0)
                    {
                        this.cname = _loc_4.eventparam;
                        _loc_8 = int(_loc_4.dir);
                        GuideView.getInstance().openPlugin(_loc_4.id, this.cname, _loc_8);
                        this.close();
                        if (this.cname == "zbhsy")
                        {
                            this.timeoutID1 = setTimeout(this.autoTask, 20000);
                        }
                        else
                        {
                            ModelProxy.change("zone", "stopGuaji", null);
                        }
                    }
                    else
                    {
                        this.autoTask();
                    }
                }
                else
                {
                    this.autoTask();
                }
            }
            else if (this.cfgtask[this.candotask.taskid].fnpc == this.cfgtask[this.taskid].tnpc)
            {
                _loc_9 = this.cfgtask[this.candotask.taskid].fnpc;
                _loc_10 = this.cfgnpcs[_loc_9];
                this.show({npcid:_loc_10.npcid, taskid:this.candotask.taskid});
            }
            return;
        }// end function

        public function autoTask() : void
        {
            var _loc_3:int = 0;
            var _loc_4:int = 0;
            if (this.candotask == null)
            {
                return;
            }
            if (this.timeoutID1)
            {
                clearTimeout(this.timeoutID1);
                this.timeoutID1 = 0;
                PluginManager.instance.closePlugin(this.cname);
                if (this.cname == "zbhsy")
                {
                    ModelProxy.change("plugin", "close", "bag");
                }
            }
            var _loc_1:int = 0;
            if (this.candotask.state == 1)
            {
                _loc_1 = this.cfgtask[this.candotask.taskid].fnpc;
            }
            else if (this.candotask.state == 2)
            {
                if (PluginManager.instance.getPluginState("taskdialog") == "open")
                {
                    this.close();
                }
                ModelProxy.change("tasktrack", "togoal", this.candotask.taskid);
                return;
            }
            else
            {
                if (PluginManager.instance.getPluginState("taskdialog") == "open")
                {
                    this.close();
                }
                ModelProxy.change("tasktrack", "dosome", this.candotask.taskid);
                return;
            }
            this.tnobj = this.cfgnpcs[_loc_1];
            var _loc_2:* = ModelProxy.getValue("data", "user");
            if (this.cfgtask[this.candotask.taskid].fnpc != this.cfgtask[this.candotask.taskid].tnpc || (Math.abs(_loc_2.x - int(this.tnobj.x)) > 5 || Math.abs(_loc_2.y - int(this.tnobj.y)) > 5))
            {
                if (PluginManager.instance.getPluginState("taskdialog") == "open")
                {
                    this.close();
                }
                _loc_3 = ModelProxy.getValue("data", "user.level");
                _loc_4 = ModelProxy.getValue("data", "user.rein");
                if (_loc_3 >= 70 || _loc_4 > 0)
                {
                    return;
                }
                ModelProxy.change("data", "taskfindpath", this.tnobj.npcid);
                ModelProxy.change("zone", "stopGuaji", null);
                ModelProxy.change("zone", "autoMove", {x:this.tnobj.x, y:this.tnobj.y, tostageid:this.tnobj.stageid, onhorse:true});
            }
            else
            {
                this.show({npcid:this.tnobj.npcid, taskid:this.candotask.taskid});
            }
            return;
        }// end function

        public function get pdvisible() : Boolean
        {
            return this._pdvisible;
        }// end function

        public function set pdvisible(param1:Boolean) : void
        {
            this._pdvisible = param1;
            return;
        }// end function

        private function onClose(event:MouseEvent) : void
        {
            this.close();
            NewGuideView.getInstance().doGuide(GuideType.GUIDE_RW);
            return;
        }// end function

        private function close() : void
        {
            ModelProxy.change("plugin", "close", "taskdialog");
            if (NewGuideView.getInstance().gid == GuideType.GUIDE1 || NewGuideView.getInstance().gid == GuideType.GUIDE2)
            {
                NewGuideView.getInstance().hide();
            }
            if (this.timeoutID)
            {
                clearTimeout(this.timeoutID);
                this.timeoutID = 0;
            }
            return;
        }// end function

    }
}
